Conversation
ea9e0ef to
d01c936
Compare
xytan0056
commented
Jul 7, 2026
| - shared metric-name, op-name, and tag-key constants | ||
| - default histogram buckets sized for RPC latency and large target counts | ||
| - an in-flight gauge helper that owns the atomic counter callers otherwise reinvent | ||
| - a failure classifier that reuses the errors package |
Contributor
Author
There was a problem hiding this comment.
@justinwon777 place holder for errors package design RFC
f8b5223 to
a1249f6
Compare
Ports the Tango Metrics Inventory RFC into the repo. Covers the Emitter contract, buckets, TrackInFlight, RecordFailure, context propagation, shared constants, and OSS / internal / CLI usage.
sywhang
reviewed
Jul 8, 2026
|
|
||
| ## Emitter | ||
|
|
||
| `Emitter` is an interface. `New(scope)` returns the default tally-backed implementation; `New(nil)` returns one backed by `tally.NoopScope` so callers do not need to special-case unwired metrics. This also serves as a noop fallback. |
Contributor
There was a problem hiding this comment.
Suggested change
| `Emitter` is an interface. `New(scope)` returns the default tally-backed implementation; `New(nil)` returns one backed by `tally.NoopScope` so callers do not need to special-case unwired metrics. This also serves as a noop fallback. | |
| `Emitter` is an interface. `New(scope)` returns the default tally-backed implementation; `New(nil)` returns one backed by `tally.NoopScope` so callers do not need to special-case metrics using alternative metrics library than tally. This also serves as a no-op fallback which could be useful for things like tests. |
Comment on lines
+51
to
+55
| `New(scope)` returns the default tally-backed implementation; `New(nil)` returns one backed by `tally.NoopScope` so callers do not need to special-case unwired metrics. | ||
|
|
||
| `Tagged` returns a child Emitter that adds tags to every subsequent emission. The parent is unchanged. The child shares the in-flight counter map, so a `TrackInFlight` increment on a parent and its decrement on a tagged child balance to zero. | ||
|
|
||
| Options are variadic and compose. `WithTags` merges into the base tag set with later-wins semantics on key collision. `WithDurationBuckets` / `WithValueBuckets` override the emitter's default histogram buckets on a single call. |
Contributor
There was a problem hiding this comment.
can this section be written as a docstring with func signature?
// New returns the default Tally-backed Emitter implementation.
func New(scope tally.Scope) Emitter
// and so on... |
|
||
| Options are variadic and compose. `WithTags` merges into the base tag set with later-wins semantics on key collision. `WithDurationBuckets` / `WithValueBuckets` override the emitter's default histogram buckets on a single call. | ||
|
|
||
| ## Op-as-subscope |
|
|
||
| Every emit call takes an op name as its first argument. `e.Inc("get_target_graph", "requests")` emits under `<scope>.get_target_graph.requests`. Consumers that own their own ops (an extension RPC, a background job) should declare `const opXYZ = "xyz"` next to the emit site rather than adding to `names.go`. | ||
|
|
||
| ## TrackInFlight |
Contributor
There was a problem hiding this comment.
same thing here, let's make this into an API form.
|
|
||
| Every RPC calls one of: | ||
|
|
||
| - `e.Inc(op, Requests, WithTags({result: success}))` on the happy path |
Contributor
There was a problem hiding this comment.
Inc and RecordFailure aren't intuitive names for counterparts of each other. can we rename?
Contributor
There was a problem hiding this comment.
Also, not sure why is Inc and failure/success is a thing. Do we need this?
|
|
||
| ## Constants | ||
|
|
||
| All shared constants live in `names.go`: operation names (`OpGetTargetGraph`, `OpGetChangedTargets`, ...), metric names (`Requests`, `TotalDuration`, `InFlightRequests`, ...), tag keys (`TagRepo`, `TagEmitter`, `TagResult`, `TagFailureType`, `TagFailureSource`, ...), and `Result*` values (`ResultSuccess`, `ResultFail`, `ResultHit`, `ResultMiss`). |
Contributor
There was a problem hiding this comment.
where they live isn't relevant to this RFC.
Can we make this into a table form?
32c02ad to
cf7326b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
add Tango Metrics Inventory RFC into the repo. Covers the Emitter contract, metrics invetnory, context propagation design and other utils and their usage.